package test
{
	import flash.events.Event;
	
	import org.abio.XasML.rpc.classLoader;
	import org.abio.XasML.rpc.command;
	import org.abio.XasML.rpc.commandChain;
	import org.abio.XasML.rpc.connectionService;
	import org.abio.XasML.rpc.staticLoader;
	
	public class rpc
	{
		public function rpc()
		{
		}

		private function onResult(re:Object):void{
			trace(re);
		}
		
		private function onFault(fe:Object):void{
			trace(fe);
		}

		public function testStaticLoader():void{
			var sl:staticLoader=new staticLoader('http://localhost:8080/');
			var cmd:command=new command(sl['component/component_2.swf'], onResult, onFault);
			cmd.execute();
		}
		
		public function testClassLoader():void{
			var cl:classLoader=new classLoader('http://localhost:8080/component/component_1.swf');
			var cmd1:command=new command(cl['component.component_1_class_1'], onResult, onFault);
			cmd1.execute();
			var cmd2:command=new command(cl['component.component_1_class_2'], onResult, onFault);
			cmd2.execute();
		}
		
		public function testConnectionService():void{
			var cs:connectionService=new connectionService('http://localhost:4277/testMXML/Gateway.aspx');
			var cmd:command=new command(cs['test.conn.test'], onResult, onFault);
			cmd.execute('asdasd');
		}
		
		public function testCommandChain():void{
			var cc:commandChain=new commandChain(commandChain.SERIES);
			cc.add(new command(new connectionService('http://localhost:4277/testMXML/Gateway.aspx')['test.conn.test'], onResult),'asd');
			cc.add(new command(new connectionService('http://localhost:4277/testMXML/Gateway.aspx')['test.conn.test'], onResult),'dsa');
			cc.add(new command(new staticLoader('http://localhost:8080/')['component/component_1.swf'], onResult, onFault));
			cc.add(new command(new staticLoader('http://localhost:8080/')['component/component_2.swf'], onResult, onFault));
			cc.addEventListener(Event.COMPLETE, function COMPLETE(e:Event):void{
				trace('cc');
			});
			cc.proceed();
		}
	}
}